/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.fileSystem;

import java.util.ArrayList;
import java.util.List;

import org.nudt.jCloud.infrastructure.Host;
import org.nudt.jCloud.infrastructure.Slot;

public class Block {
	private int id;
	private int length;
	private List<Host> hostList;
	
	public Block(int length){
		setId(-1);
		setLength(length);
		setHostList(new ArrayList<Host>());
	}
	
	public boolean locality(Slot slot){
		if(slot == null){
			return false;
		}else{
			for(int i=0; i<hostList.size(); ++i){
				if(hostList.get(i).getId()==slot.getHost().getId()){
					return true;
				}
			}
			return false;			
		}
	}
	
	public void store(Host host){
		hostList.add(host);
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public List<Host> getHostList() {
		return hostList;
	}
	public void setHostList(List<Host> hostList) {
		this.hostList = hostList;
	}

}
